layui.use(['form','jquery'],function () {
    var form = layui.form,
        $ = layui.jquery;
    form.on("submit(submitBtn)",function (data) {
        var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
        var obj = data.field;
        console.log(obj);
        /**
         * 请求后台
         */
        $.ajax({
            type:'POST',
            url:'/commentController/add',
            data:JSON.stringify(obj),
            dataType:'json',
            contentType:'application/json',
            success:function (res) {
                /**
                 * 添加成功后回调
                 **/
                setTimeout(function(){
                    top.layer.close(index);
                    top.layer.msg("感谢您的宝贵评论,谢谢！");
                    layer.closeAll("iframe");
                    //刷新父页面
                    parent.location.reload();
                },500);
                return false;
            }
        });
    })
});